package com.ejd.web.vo.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import java.util.List;

import com.ejd.utils.DESPlusUtil;
import com.ejd.web.bo.AbstractGoods;
import com.ejd.web.bo.impl.GoodsProperties;
public class GoodsVo extends AbstractGoods {
	private ProductunitVo unitv;
	private StakeholderVo providerv;
	private List<GoodsPropertiesVo> propertiesv = new ArrayList<GoodsPropertiesVo>();
	public GoodsVo(){
		if (null == unitv) {
			unitv = new ProductunitVo();
		}
		if (null == providerv) {
			providerv = new StakeholderVo();
		}
	}
	public ProductunitVo getUnitv() {
		return unitv;
	}
	public void setUnitv(ProductunitVo unitv) {
		this.unitv = unitv;
	}
	public StakeholderVo getProviderv() {
		return providerv;
	}
	public void setProviderv(StakeholderVo providerv) {
		this.providerv = providerv;
	}
	public List<GoodsPropertiesVo> getPropertiesv() {
		return propertiesv;
	}
	public void setPropertiesv(List<GoodsPropertiesVo> propertiesv) {
		this.propertiesv = propertiesv;
	}
	
	public String getVoShowImage() {//用于没有多个属性的值 image直接存储在主数据中
		String result = "";
		if (null != this.getImage1() && !("".equals(this.getImage1()))) {
			result = this.getImage1();
		}
		return result;
	}
	public List<String> getVoImages() {
		List<String> result = new ArrayList<String>();
		if (null != this.getImage1() && !("".equals(this.getImage1()))) {
			result.add(this.getImage1());
		}
		if (null != this.getImage2() && !("".equals(this.getImage2()))) {
			result.add(this.getImage2());
		}
		if (null != this.getImage3() && !("".equals(this.getImage3()))) {
			result.add(this.getImage3());
		}
		if (null != this.getImage4() && !("".equals(this.getImage4()))) {
			result.add(this.getImage4());
		}
		if (null != this.getImage5() && !("".equals(this.getImage5()))) {
			result.add(this.getImage5());
		}
		if (null != this.getImage6() && !("".equals(this.getImage6()))) {
			result.add(this.getImage6());
		}
		if (null != this.getImage7() && !("".equals(this.getImage7()))) {
			result.add(this.getImage7());
		}
		if (null != this.getImage8() && !("".equals(this.getImage8()))) {
			result.add(this.getImage8());
		}
		if (null != this.getImage9() && !("".equals(this.getImage9()))) {
			result.add(this.getImage9());
		}
		if (null != this.getImage10() && !("".equals(this.getImage10()))) {
			result.add(this.getImage10());
		}
		
		return result;
	}
	public Map<String,String> getVoPropertiesMapShowImages() {//用于有多个属性的值 image直接存储在附加属性中,显示第1幅图片的
		Map result = new HashMap<String,String>();
		if (null != getPropertiesv() || !(getPropertiesv().isEmpty())) {
			for (GoodsPropertiesVo property:getPropertiesv()) {
				String mapKey = this.getCode()+property.getColor();
				result.put(mapKey, property.getSfield1());
			}
		}
		return result;
	}
	
	public Map<String,List<String>> getVoPropertiesMapImages() {//用于有多个属性的值 image直接存储在附加属性中,显示第1幅图片的
		Map result = new HashMap<String,List<String>>();
		if (null != getPropertiesv() || !(getPropertiesv().isEmpty())) {
			for (GoodsPropertiesVo property:getPropertiesv()) {
				List<String> imageList = new ArrayList<String>();
				imageList.add(property.getSfield1());
				imageList.add(property.getSfield2());
				imageList.add(property.getSfield3());
				imageList.add(property.getSfield4());
				imageList.add(property.getSfield5());
				imageList.add(property.getSfield6());
				imageList.add(property.getSfield7());
				imageList.add(property.getSfield8());
				imageList.add(property.getSfield9());
				imageList.add(property.getSfield10());
				String mapKey = this.getCode()+property.getColor();
				result.put(mapKey, imageList);
			}
		}
		return result;
	}
	public String getVoDesId() {
		return DESPlusUtil.encrypt(this.getId().toString());
	}
	public String getVoDesCode() {
			return DESPlusUtil.encrypt(this.getCode());
	}
	public String getVoDesPrimaryCategoryCode(){
		return DESPlusUtil.encrypt(this.getPrimaryCategoryCode());
	}
}
